package com.example.service.impl;

import com.example.config.RabbitMQConfig;
import com.example.model.Event;
import com.example.service.EventPublisher;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
@Slf4j
public class RabbitMQEventPublisher implements EventPublisher {
    
    private final RabbitTemplate rabbitTemplate;
    
    @Override
    public void publishEvent(Event event, String routingKey) {
        log.info("Publishing event: {}, with routing key: {}", event, routingKey);
        rabbitTemplate.convertAndSend(RabbitMQConfig.MAIN_EXCHANGE, routingKey, event);
    }
} 